﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using PPI.Client.Interface;
using PPI.Client.Presenter;
using PPI.Entities;

namespace PPI.CRUD
{
    public partial class frmEditUser : frmBase, IEditUser
    {
        private EUser m_User;
        private EditUserPresenter m_presenter;

        public frmEditUser()
        {
            InitializeComponent();
            this.MenuMain.Visible = false;
            m_presenter = new EditUserPresenter(this);
        }

        public EUser User
        {
            get { return m_User; }
            set { m_User = value; }
        }

        private void btnSave_Click(object sender, EventArgs e)
        {
            m_User.Username = txtUsername.Text;
            m_User.Password = txtPassword.Text;
            m_User.IsAdministrator = chkIsAdministrator.Checked;
            m_presenter.Save();
            this.Close(); ;
        }

        private void frmEditUser_Load(object sender, EventArgs e)
        {
            txtUsername.Text = m_User.Username;
            txtPassword.Text = m_User.Password;
            chkIsAdministrator.Checked = m_User.IsAdministrator;
        }

        private void btnCancel_Click(object sender, EventArgs e)
        {
            this.Close(); ;
        }
    }
}
